import { ModalForm, ProFormText } from '@ant-design/pro-components';

export type EditFormProps = {
  title: string;
  open: boolean;
  onOpenChange: React.Dispatch<React.SetStateAction<boolean>>;
  onFinish: (values: API.RoleItem) => Promise<void>;
  values?: Partial<API.RoleItem>;
};

const EditForm: React.FC<EditFormProps> = (props) => {
  return (
    <ModalForm
      title={props.title}
      open={props.open}
      onOpenChange={props.onOpenChange}
      onFinish={props.onFinish}
      initialValues={props.values}
      modalProps={{ destroyOnClose: true }}
    >
      <ProFormText
        label="角色名称"
        name="name"
        rules={[{ required: true, message: '请填写角色名称' }]}
      />
    </ModalForm>
  );
};

export default EditForm;
